<template>
	<view class="ikz-bid">
    <ikz-loading  :css-data="loading_css"></ikz-loading>
    <!-- list -->
    <ikz-topbg></ikz-topbg>
    <view>
      <ikz-orderdetail :show-data="show_info" :receiver="isReceiver"></ikz-orderdetail>
    </view>
    <!-- list -->
	</view>
</template>

<script>
import ikzLoading from '@/pages/Component/Public/Loading/loading.vue';
import ikzOrderdetail from '@/pages/Component/Public/Orderdetail/public/orderdetail/orderdetail.vue';
import ikzTopbg from '@/pages/Component/Public/Topbg/public/topbg/topbg.vue';
var app = getApp();
import ikz from '@/pages/Common/tools.js';
export default {
	components: {
    ikzLoading,
    ikzOrderdetail,
    ikzTopbg
	},
	data() {
		return {
			// 是否为接单员
			isReceiver:0,
      id:'',
      loading_css:{
        display:'flex',
      },
      show_info:{}
    };
	},
  onLoad(options){
	if(options){
		this.id = options.id;
	}else{
		console.log("options值是",options);
	}
    this.detailInfo((res)=>{
      this.loading_css.display = 'none';
    });
  },
  created() {
		// var that = this;
  },
  onShareAppMessage() {
  	return {
  		title: '订单详情',
  		path: '/pages/Component/Module/Campus/Program/Order/detail/index?id=' + this.id,
  	}
  },
  onShow(){
	  this.handleReceiver()
  },
	methods: {
		//请求页面数据
		detailInfo(fn) {
			var path = '/xyb/order/detail';
			var data = {
				id:this.id
			};
			ikz.post(path, data, res => {
				if (res.data.code) {
					this.show_info = res.data.data;
				} else {
					uni.showModal({
						title: '提示',
						content: res.data.msg,
						showCancel: false,
						success: function(res) {}
					});
				}
				fn();
			});
		},
		// 判断是否是接单员
		handleReceiver() {
			var path = '/xyb/user/is_receiver';
			var url = app.globalData.adminPath + path;
			var data = {
				app_plat: "MP-WEIXIN",
				token: uni.getStorageSync('local_user_session'),
				agent_id: uni.getStorageSync('default_agent').id||''
			}
			if(data.token){
				uni.request({
					url: url,
					header: {
						"Content-Type": "application/x-www-form-urlencoded"
					},
					data: data,
					method: 'POST',
					success: (res)=> {
						uni.setStorageSync('receivers', res.data.data.is_receiver)
						this.isReceiver=res.data.data.is_receiver
					},
					fail: function(res) {
						//调用接口失败或回传失败
						uni.showModal({
							title: '服务器繁忙',
							content: '服务器繁忙或网络不稳定，请稍后再试！'
						})
					},
				})
			}
		},
		
		//跳转至招聘中心
		getRecriut(){
			let url = '/pages/Component/Module/Demand/Program/Recruit/index';
			ikz.nav(url, 'n');
		},

	}
};
</script>

<style>
  page{
    width: 100%;
    height: 100%;
    background: #F3F3F3;
  }
  /* ad */
</style>
